<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@ include file="/jsp/common/common.jsp" %>
<%
String jobName = request.getAttribute("jobName") == null?"":request.getAttribute("jobName").toString();
String jobGroup = request.getAttribute("jobGroup") == null?"":request.getAttribute("jobGroup").toString();
%>
</head>
<body>

<div class="tableMainWarp">
  <div>
    <table width="100%" border="0" cellpadding="0" cellspacing="0" class="search-table">
      <tr>
      	<td width="10%">任务执行类：</td>
      	<td width="40%"><input class="table-input" id="jobClass" name="jobClass" value=""/></td>
      	<td width="10%">任务描述：</td>
      	<td width="40%"><input class="table-input" id="description" name="description" value=""/></td>
      </tr>		
      <tr>
      	<td>任务名称：</td>
      	<td><input class="table-input" id="jobName" name="jobName" value=""/></td>
      	<td>任务组名：</td>
      	<td><input class="table-input" id="jobGroup" name="jobGroup" value=""/></td>
      </tr>
      <tr>
	      <td></td>
	      <td></td>
	      <td></td>
	      <td>
	    	<button class="btn-table" id="saveJobButton">保存</button>
	    	<button class="btn-table" id="addPlanButton">添加计划</button>
	    	<button class="btn-table" id="deletePlanButton">删除计划</button>
	      </td>
      </tr>
      
      	
    </table>
  </div>
  <div class="tablelist" style="margin-right: 20px;">
    <div class="tabcon" id="middleCon"  style="overflow: auto;"></div>
    <div id="paginationDiv"  class="page clearfix"></div>
  </div>
  
  <div style="display: none">
  	<input type="text" name="jobName" id="jobNameHidden" value="<%=jobName %>" />
  	<input type="text" name="jobGroup" id="jobGroupHidden" value="<%=jobGroup %>" />
  </div>
</div>


<script type="text/javascript">

$(document).ready(function(){
	
	var bodyHt=document.documentElement.clientHeight;
	var tableDivHeight = bodyHt-167;	
	$('#middleCon').height(tableDivHeight);
	
	getPageData();

	initTable();
	
	blindPageElement();
	
});

function blindPageElement(){

	//绑定查询按钮
	$('#searchButton').on('click',function(){
		
		$('#middleCon').tablegrid('reload',{
			jobName : $('#jobName').val(),
			jobGroup : $('#jobGroup').val()
		});
	});
	
	//绑定添加按钮
	$('#saveJobButton').on('click',function(){
		
		var jsonData = {
			jobClass: $('#jobClass').val(),
			description: $('#description').val(),
			jobName: $('#jobName').val(),
			jobGroup: $('#jobGroup').val()
		};
		
		var jsonDataStr = JSON.stringify(jsonData);
		var url = "<%=basePath%>/webframework/scheduler/saveJobDetail.do";
		$.ajax({
			url : url,
			type : 'post',
			dataType : 'json',
			data:{jsonData:jsonDataStr},
			success : function(data, textStatus, jqXHR) {
				showAlert('添加成功');
				$('#jobNameHidden').val(data.data.jobName);
				$('#jobGroupHidden').val(data.data.jobGroup);
				
			},
			error : function(XMLHttpRequest, textStatus, errorThrown) {
			}
		});
	});
	
	
	
}

function initTable(){
 	
	var url = "<%=basePath%>/webframework/scheduler/getJobTriggerList.do?";
	url = url + 'jobName='+$('#jobNameHidden').val();
	url = url + '&jobGroup='+$('#jobGroupHidden').val();
	
	$('#middleCon').tablegrid({
		url: url,
		columns:[	
		         	{field:'tiggerName',ischeckbox:true,align:'center',width:4},
		   	        {field:'tiggerName',title:'计划名称',width:10},
		   	        {field:'tiggerGroupName',title:'计划组名',width:10},
		   	     	{field:'description',title:'计划描述',width:16},
		   	        {field:'triggerState',title:'计划状态',width:10},
		   	     	{field:'previousFireTime',title:'上次执行时间',width:20},
		   	        {field:'nextFireTime',title:'下次执行时间',width:20},
		   	        {field:'tiggerType',title:'计划类型',width:10}
			    ],
	    isPagination:true,
	    resizeColumns : true,
	    isFristData:false,
	    pageConifg:{
	    	pageId : 'paginationDiv'
	    },
	    tableClass : 'table-form'
	});
}


function getPageData(){
	
	
}



</script>
</body>
</html>